package com.pan.structual.facade.facade.impl;

import com.pan.structual.facade.component.FrameCreate;
import com.pan.structual.facade.component.ShapeCreate;
import com.pan.structual.facade.component.TextCreate;
import com.pan.structual.facade.facade.DrawFacade;

import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;


/**
 * 依赖倒置
 *
 * 面向接口编程
 */
public class DrawShapeAndTextFacade implements DrawFacade {


    FrameCreate frameCreate = new FrameCreate();
    ShapeCreate shapeCreate = new ShapeCreate();
    TextCreate textCreate = new TextCreate();

    public void printShape(String shape, Color color, String text) {
        shapeCreate.setShape(shape);
        shapeCreate.setColor(color);
        BufferedImage shapeImage = shapeCreate.getShapeImage();
        JLabel textLabel = textCreate.getLabel(text);
        frameCreate.printShape(shapeImage, textLabel);
    }


}
